<template>
	<view class="content_view">
		<u-navbar title-color="#FFFFFF" back-icon-color="#FFFFFF" height="48" :is-back="true" title="个人中心" :border-bottom="false">
			<view class="u-flex u-row-right" style="width: 100%;">
				<view class="camera u-flex u-row-center">
					<u-icon name="scan" color="#FFFFFF" size="48" @click="scanQr"></u-icon>
				</view>
			</view>
		</u-navbar>
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30" style="margin-top: 10px;">
			<view class="u-m-r-10">
				<u-avatar :src="userInfo.avatar||pic" size="140"></u-avatar>
			</view>
			<view class="u-flex-2">
				<view class="u-font-18 u-p-b-20">{{userInfo.name}}</view>
				<view class="u-font-14 u-tips-color">帐号:{{userInfo.userName}}</view>
			</view>
			<view class="u-m-l-10 u-p-10">
			</view>
			<view class="u-m-l-10 u-p-10">
				<u-icon name="arrow-right" color="#969799" size="28" @click="toUserInfo"></u-icon>
			</view>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="tasking" title="我的任务" @click="tasking"></u-cell-item>
				<u-cell-item icon="tasking" title="消息中心" @click="myNotice"></u-cell-item>
				<!-- <u-cell-item icon="tasking" title="签到中心" @click="sign"></u-cell-item>
				<u-cell-item icon="tasking" title="个人工作" @click="personWork"></u-cell-item> -->
			</u-cell-group>
		</view>

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item  title="退出" @click="logOut"></u-cell-item>
			</u-cell-group>
		</view>
	</view>
</template>

<script>
	import store from "../../store/index.js"
	export default {
		data() {
			return {
				pic:'https://ifire-test.oss-cn-beijing.aliyuncs.com/avatar/admin/ADMIN123456524/2021/01/5e3af597-14b1-4d3a-a1b6-90ae6833e085.jpg',
				show:true,
				inactiveColor: '#909399',
				activeColor: '#5098FF',
				userInfo:{}
			}
		},
		onShow() {
			this.getUserInfo()
		},
		methods: {
			getUserInfo(){
				this.utils.request("/api/app/user/getUserInfo",{},"get","app",true).then(res=>{
					console.log(res)
					this.userInfo = res.data
					store.dispatch("user/setUserInfo",this.userInfo)
				}).catch(error=>{
					console.log(error)
				})
			},
			toUserInfo(){
				uni.navigateTo({
					url:"/pages/account/info"
				})
			},
			scanQr(){
				window.native.scanCode()
			},
			settings(){
				uni.navigateTo({
					url:"/pages/account/settings"
				})
			},
			tasking(){
				uni.navigateTo({
					url:"/pages/index/task/list"
				})
			},
			sign(){
				uni.navigateTo({
					url:"/pages/index/sign/index"
				})
			},
			personWork(){
				uni.navigateTo({
					url:"/pages/index/personWork/list"
				})
			},
			myNotice(){
				uni.navigateTo({
					url:"/pages/index/notice/list"
				})
			},
			logOut(){
				this.$store.commit('webSocket/WEB_SOCKET_CLOSE')
				this.utils.request("/api/app/user/logOut",{ucId:this.userInfo.ucId,online:0},"post","app",true).then(res=>{
				uni.removeStorage({
					key:"authorization",
					success() {
						uni.redirectTo({
							url:'/pages/start'
						})
					}
				})
				window.native.closeAudio(1)
				window.native.closeAudio(2)
				window.native.closeAudio(3)
				window.native.closeAudio(4)
				window.native.closeAudio(5)
				window.native.closeAudio(6)
				window.native.closeAudio(7)
				window.native.closeAudio(8)
				window.native.closeAudio(9)
                 window.native.deleteJgAccount(this.userInfo.ucId,res=>{
                     console.log(res)
                 })
				}).catch(error=>{

				})
			}

		}
	}
</script>

<style lang="scss" scoped>
page{
	background-color: #ededed;
}

.camera{
	width: 54px;
	height: 44px;

	&:active{
		background-color: #ededed;
	}
}
.user-box{
	background-color: #fff;
}
</style>
